wkt script with shapely

parent 65f57ac2
from django.core.management.base import BaseCommand, CommandError
from catalog.models import Polygon
import json
from shapely.geometry import shape
class Command(BaseCommand):
def handle(self, *args, **options):
polygons = self._ignore(Polygon.objects.all(), 'santa lucia aeropuerto')
for index, polygon in enumerate(polygons):
geometry = self._get_geometry(polygon)
shapely_geometry = shape(geometry)
polygon.wkt_polygon = shapely_geometry.wkt
polygon.save()
print('polygon %s updated c;'%index)
def _get_geometry(self, polygon):
info = json.loads(polygon.json_info)
return info['geometry']
def _ignore(self, polygons, names):
to_ignore = names.split(',')
return [p for p in polygons if p.name not in to_ignore]
......@@ -19,11 +19,6 @@ configfile = os.path.join(dirname, '../config/config.json')
with open(configfile, 'r') as f:
config = json.load(f)
print(config['PATHS']['PATH_GEOSENTINEL'])
print(config['PATHS']['PATH_NAS'])
print(config['API_SENTINEL']['SENTINEL_USER'])
print(config['API_SENTINEL']['SENTINEL_PASS'])
NAS_PATH = config['PATHS']['PATH_NAS']
USERS_PATH = config['PATHS']['PATH_USERS']
SENTINEL_PATH = config['PATHS']['PATH_GEOSENTINEL']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment