Article Tag: Python

Accessing the OpenStreetMap API with Python directly


Posted on 2024-04-16, by Racum. Tags: GIS OpenStreetMap JSON Python Shapely

On a previous article called "OpenStreetMap to GeoJSON", I explained how to extract Polygons from OSM using an online tool provided by from OSM France. And, on this article, I’ll explain how do that yourself directly using the OSM API and Python.

This also explains the basic concepts I used to write the osmexp tool, to export OSM elements into GeoJSON from the command-line.

Shapely example: Where to build cell-towers?


Posted on 2024-01-27, by Racum. Tags: GIS Python GeoJSON Shapely

This is a fun example of how to use Shapely to solve geographical problems. On this article I show how to cover a polygon with circles in a hexagonal pattern.

Promoting simple Django fields to ForeignKeys


Posted on 2024-01-23, by Racum. Tags: Django Python

Did you ever change your mind about your Django database structure? Sometimes you need to create references between models, but for some reason you didn’t use a ForeignKey field, and there are good cases for that, for example: the ID came from a different system, but you decided to have a local copy. On this article I show how to convert it the proper way.

Calculate local time with UTC and location


Posted on 2024-01-05, by Racum. Tags: GIS Python GeoJSON

When working with remote sensing, it is very common to save time data in a single timezone (usually UTC), this article shows how to convert that into local time based on the provided coordinates.

Converting projections on Shapely


Posted on 2023-12-24, by Racum. Tags: GIS Python GeoJSON

Sometimes when dealing with coordinates, you may need to work in meters instead of degrees, but, since we don’t live in a flat earth, the calculation is not trivial. Thankfully, there are tools to help with the conversions.

Minimal Docker for GeoDjango + PostGIS


Posted on 2023-12-03, by Racum. Tags: GIS Python Django PostgresSQL Docker

If you want to dockerize a GeoDjango project, the most common method is to use an oficial Python image as its base, and install all GIS dependencies over it, being GDAL the heaviest one, making your final image easily reach the mark of the multi-megabytes. But GDAL is very modular, and most GeoDjango projects can work fine with its basic compilation.

This article shows how to flip that dependency, and use the official minimal GDAL images as a basis, adding the Python/Django structure over it. Also, how to pick a leaner PostGIS image to save even more space on your development environment.