0

I have photoindex, each tile is a georeferenced jpg and I have a list of coordinates that can be represented as point.

If a point is contained in a tile, I must put a symbol in that tile where the point is to save the tile as jpg using the id of the point as the filename.

Is there an easy way to do this with a lot of points (thousands)?

I know some Python.

Edit: So I have found a way to do it. I'm pretty sure I can still improve some steps but it works.

  1. Make a tile index from the rasters with QGIS tool Tile Index
  2. Convert coordinates to points
  3. Add polygon attributes (From the tile index layer we are gonna take the attribute "name", that is the name of the raster) to points (the coordinates)
  4. Now some python. Iterate through all points
    • With the new database from the result of step 3. From the newly added column take the name of the raster and open it with rasterio.open() function
    • Then use rasterio method ".index()" this will take the coordinates to convert them to pixel coordinates (the raster projection and the given coordinates must be on the same projection)
    • Use PIL to draw a circle on the image in the given pixel coordinates

Later I'll put the code

  • 1
    Welcome to GIS StackExchange, If you want help about python, the rule is to put some code to prove that your tried to do it. Else you can change your tag Python and edit your question – Svhooren Jan 8 at 6:54
  • That sounds challaging. For a python based solution: Do you know pillow: https://pillow.readthedocs.io/en/stable/? It can draw on images. But you'll have to deal with georeferentiation and turn real world coordinates into pixel indices of the tiles. – Andreas Müller Jan 8 at 16:27
  • yeah. that was my first thought, however i wanted to know if there was some other simplier way. However im reading that transform coordinates to pixels isnt that hard. And i imagine pillow wouldnt be that hard. So maybe – need help Jan 9 at 2:58
  • What GIS software are you using? – PolyGeo Jan 9 at 5:36
1

You can probably do this in a GIS software. Here's a rough outline of how I would go about doing this in QGIS. Some of the steps are a bit fuzzy on details, but I think this will be enough to get you started.

  1. Import the points as a delimited text layer. Here's a tutorial.
  2. Apply a symbology to the point layer that looks like the symbol you want to burn into the georeferenced tiles.

    • If the QGIS symbol library has the symbol you want, use a "simple marker" style with that symbol. Choose your desired color, size and rotation for the symbol.
    • If you have the symbol as an SVG file, use an SVG marker style.
    • If you have the symbol as a normal image file (eg jpg format), use a "filled marker" style with a "raster image fill".
  3. If the symbol has any white in it, and you want the white to be preserved in the final product, change the map canvas background to a different color. Note that we're going to make that color transparent in a later step, so choose a color that's not in the symbol.
  4. Export the symbols as a raster or rasters. Here are a couple of suggested methods, but there's probably a better way I haven't thought of. The end goal is simply to convert your point symbols into raster images. Ideally, they would be a series of thousands of tiny rasters instead of one big raster.

    • The easy way is to export the point symbols as a single georeferenced image: Project Menu > Import/Export > Export map to image. But obviously if you have a large extent and detailed symbols, this will make an enormous file.
    • If the output from doing it the easy way will be unreasonably large, you could instead export it as a series of tiles, like this: Generating Tiles with QGIS?
    • There's probably a more efficient way of doing this step. Suggestions?
  5. Set the background color as a nodata value for the point symbol raster. (This is the color you chose in step 3.)

  6. If the point symbol rasters are separate rasters, combine them into a single virtual raster: Joining several raster files using QGIS?

  7. Import the georeferenced tiles: Open local Raster Tiles in QGIS

  8. Combine the tiles into a single virtual raster: Joining several raster files using QGIS?

  9. Use the Raster Calculator to combine the two rasters.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.