Lets take a look at the ‘Sierra de la Demanda’ (northern Spain) and see if there is significant snow over there this days. We are going to get the images from the Copernicus SciHub service.
Disclaimer: Only Open Source Software was used during this process
This post will will show you how to build a very simple application that uses leaflet js with browserify.
why do you want to do that?
I’m using Ubuntu 15.04 and it comes with Python 2.7 and Python 3.4 pre-installed.
Installing into this Python installation requires root access to the system and it may be better to use a virtual environment when installing packages with pip, which is a little confusing. Also, if you are on a Windows machine installing packages may be complicated.
To me the easier solution to setting up a geospatial environment is to use Conda (a open source, cross platform package manager application that installs, runs, and updates packages and their dependencies) and doesn’t require administrator privileges to install anything.
To install Conda, you will download Anaconda or Miniconda (both are free). Anaconda is a Python distribution that includes the most popular Python packages for science, maths, engineering, and data analysis, while Miniconda is just a conda and python installation.
Have you ever needed very specific data from openstreetmap and don’t want to download the whole state or country? The solution is Overpass API.
The Overpass API (formerly known as OSM Server Side Scripting, or OSM3S) is a read-only API that serves up custom selected parts of the OSM map data. It acts as a database over the web: the client sends a query to the API and gets back the data set that corresponds to the query.
We are going to try the Overpass QL as query language. The whole query source code is divided in statements. We set the type of element that we want: node, way, relation or area. and then filter by tag. Like this
Usually to render spatial data on a web map you need GeoJSON data of the type “FeatureCollection”, and if you have your data on a PostGIS database you can do a query to get the geometries on GeoJSON format with the ST_AsGeoJSON(geom) function. Something like this:
SELECT loc_id, loc_name, ST_AsGeoJSON(geom, 4) as geojson FROM locations;
This will return a different row for every feature that should be on the collection, so after run that query you need a function to iterate over every result to insert loc_id and loc_name as properties of every feature and push them to the array of features.
But there is a more efficient way of doing it with this single
FROM ( SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features
FROM (SELECT 'Feature' As type
, ST_AsGeoJSON(lg.geom, 4)::json As geometry
, row_to_json((SELECT l FROM (SELECT loc_id, loc_name) As l
)) As properties
FROM locations As lg ) As f ) As fc;
This is tested on a fresh installation of Ubuntu 15.04.
$ sudo apt-get install postgresql postgresql-contrib postgis postgresql-9.4-postgis-2.1 pgadmin3
# add a new user (need to be authenticated as a superuser)
$ sudo -u postgres createuser --superuser mysuperuser
# Set password for created user
$ sudo -u postgres psql postgres
postgres=# \password mysuperuser
Enter new password:mysuperuserpassword
Enter it again:
# create password for user postgre
$ sudo su
$ su - postgres
Now you can access the PostgreSQL prompt with the command:
And then change the password for postgres role by typing :
$ \password postgres
Enter new password: postgres
Some times you need to have vector data that haven’t been digitized yet, like some old maps with building footprints or street lines. We can scan a map, georeference it in QGIS, and then digitize those features to create new vector layers. Scanned maps don’t contain spatial reference information, so to digitize we need to reference the raster in a specific coordinate system.
In this example we will georeference a map of the city of Barcelona with the layout of the old medieval walls (XIII-XIV) with QGIS.
Let’s say that we need the Barcelona’s subway lines in geojson for our project, and we decided to use OpenStreetMap data. There is plenty of ways for getting OSM data, the most common is using their API, or the geofabrik download page, but this time we gonna use metro-extracts from mapzen.
We look for Barcelona. There is a lot of file formats there:
Use your github account to store geojson files has many advantages. Not only that any
.geojson file in a GitHub repository will be automatically rendered as an interactive, browsable map with in the repo. You also can embed it in any webpage.
Turf es ligero, rápido y opensource (chupate esa ArcgisOnline)