How to dynamically determine a pixel size for raster creation?

by gisdude   Last Updated July 06, 2018 16:22 PM

I have a GeoDjango web service that allows a user to upload a las file (v1.2). I can derive the extent of the point cloud coverage from the file using laspy:

from django.contrib.gis.geos import Polygon
from laspy.File import File
las_file = File('some/las/file', 'r')
xmin = las_file.header.min[0]
ymin = las_file.header.min[1]
xmax = las_file.header.max[0]
ymax = las_file.header.max[1]
bbox = Polygon.from_bbox((xmin, ymin, xmax, ymax))

...from this polygon's extent I would like to know its map scale in cm:m (projection is EPSG:3857) so I can use Waldo Tobler's rule of resolution (i.e. resolution/cell size = scale/(1000*2)) to create a raster of the point cloud.

What is the best approach here? I thought maybe creating a map object that is zoomed to the poly then accessing a scale property (e.g. scale = map.scale()) would be a good method but do not know of a python API available to do this... I see that QGIS for python has a scale calculator but am not sure how to implement with my project.

Related Questions

raster calculator in djano using python and gdal

Updated October 28, 2017 02:22 AM

GeoDjango - Use GDAL python binding in the shell

Updated August 07, 2017 20:22 PM

GDAL install path issues on Mac OSX High Sierra

Updated March 04, 2019 10:22 AM

geodjango raster add raster errors

Updated June 21, 2018 20:22 PM