I recently manually built a tile server with this instruction -> https://switch2osm.org/serving-tiles/manually-building-a-tile-server-20-04-lts/. I downloaded location data for Russia from geofabrik.de and then loaded to database by osm2pgsql. Now all working nicely - Apache, mod_tile, renderd, Mapnik and PostgreSQL with PostGIS.
Now I want to create a program on Python for generating a PNG file with specific region (box). This region will be defined by coordinates (left and right corners of box). I write this code:
import mapnik
mapnik_xml = "openstreetmap-carto/mapnik.xml"
map_output = "region_map_mapnikXml.png"
# Create a map object
m = mapnik.Map(600,300)
mapnik.load_map(m, mapnik_xml)
bbox = mapnik.Box2d(45.23, 41.34, 46.23, 43.23)
m.zoom_to_box(bbox)
mapnik.render_to_file(m, map_output)
print(f"Rendered image to {map_output}")
But after executing this code created only blank file with background. I don't figure out why? Can you help me please.
Additionaly, if I run this code:
import mapnik
mapnik_xml = "openstreetmap-carto/mapnik.xml"
map_output = "world_map_mapnikXml.png"
# Create a map object
m = mapnik.Map(600,300)
mapnik.load_map(m, mapnik_xml)
m.zoom_all()
mapnik.render_to_file(m, map_output)
print(f"Rendered image to {map_output}")
in results, generated PNG file - world map with shape of mainlands and countries.
Why is this happening?