Create a role and a database for Django:
create role user with superuser login with password '***';
create database gn_24 with owner user;
\c gn_24
| import json | |
| from geonode.maps.models import Layer, Map | |
| map = Map.objects.get(id=2512) | |
| for layer in map.layer_set.filter(ows_url__icontains='worldmap.harvard.edu/geoserver/wms'): | |
| if layer.name is None: | |
| print 'This layer is None!!!' | |
| else: | |
| print 'Fixing layer %s' % layer.name |
| {% extends "site_base.html" %} | |
| {% load i18n %} | |
| {% load url from future %} | |
| {% block title %} {{ block.super }} {% endblock %} | |
| {% block body_class %}Solr Search{% endblock %} | |
| {% block body_outer %} | |
| {% block body %} | |
| <h3>Search Metadata</h3> | |
| <form type="GET" action="."> |
| import pysolr | |
| from owslib.csw import CatalogueServiceWeb, PropertyIsEqualTo | |
| import time | |
| keywords = ( | |
| 'agriculture', | |
| 'climate', | |
| 'farming', | |
| 'health', | |
| 'ocean', |
| server{ | |
| listen 80; | |
| index index.html index.htm; | |
| root /usr/share/nginx/html; | |
| server_name example.com; | |
| location /uploaded { | |
| alias /home/ubuntu/worldmap_staging/worldmap_staging/uploaded/; | |
| } |
| import csv | |
| from geonode.maps.models import Map | |
| with open('maps_export.csv', mode='w') as export_file: | |
| export_writer = csv.writer(export_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) | |
| for map in Map.objects.all(): | |
| export_writer.writerow([map.title, map.get_absolute_url()]) |
| import argparse | |
| import os | |
| import xmltodict | |
| def do_kml2tiff_conversion(input_path, input_kml, output_path, output_tif): | |
| with open(input_kml) as f: | |
| doc = xmltodict.parse(f.read()) |
| import fiona | |
| from shapely.geometry import shape, Point | |
| def is_point_in_poly_with_iteration(shape_path, coords): | |
| print(coords) | |
| point = Point(coords) | |
| with fiona.open(shape_path) as source: | |
| for i, feat in enumerate(source): | |
| if point.within(shape(feat['geometry'])): | |
| print(f'Found it after checking {i} features!') |
| import os | |
| from osgeo import gdal | |
| def rasterize(input_shp, out_raster): | |
| # run gdal_rasterizer | |
| layer_name = os.path.basename(input_shp).split('.')[0] | |
| gdal_rasterize_cmd = f'gdal_rasterize -burn 1 -ts 1000 1000 -l {layer_name} {input_shp} {out_raster}' | |
| print(gdal_rasterize_cmd) |