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 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) |
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 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 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()]) |
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 pysolr | |
from owslib.csw import CatalogueServiceWeb, PropertyIsEqualTo | |
import time | |
keywords = ( | |
'agriculture', | |
'climate', | |
'farming', | |
'health', | |
'ocean', |
{% 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 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 |
cd /mydir | |
url="http://localhost:8080/geoserver/wms?STYLES=&FORMAT=image%2Fpng&TRANSPARENT=TRUE&LAYERS=geonode%3ADE01_SL6_22P_1T_20100521T010517_20100521T010602_DMI_0_1b5d_qXM&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&LLBBOX=137.36632816178096,36.772883864884584,141.8751878470843,40.26195796778519&URL=http%3A%2F%2Flocalhost%3A8180%2Fgeoserver%2Fwms&TILED=true&TILESORIGIN=15291549.700982,4407496.8300991&SRS=EPSG%3A900913&BBOX=15654303.390625,4657155.2587109,15693439.149102,4696291.0171875&WIDTH=256&HEIGHT=256" | |
/usr/bin/curl $url --connect-timeout 5 --max-time 20 -s -f -o /dev/null | |
if [ $? -eq 0 ] | |
then | |
: | |
else |