I'm trying to generate shapefiles from png image and isolate polygons by colors. I'm using gdal_translate to georeferencing image to GTiff and gdal_translate.py to convert GTiff to shapefile. Converting the raw image, the output shapefile is correct, but isolating one color, using imagemagick, the output shp have a colored background.

Is there any tool that would help me in this task ? And why converting to transparent is breaking my shapefile?

PS: Sorry, but I could not post the shapefile image without isolating the colors because I do not have enough reputation to post more than 2 images.

Raw file: Raw File

Shapefile with one color isolate: shapefile with one isolate color

Scripts i'm using:

      #Remove o yellow E red (d1)
    /usr/bin/convert $RAWDIR/$IMG -fuzz 2%  -transparent "#6A6A00" -transparent "#6A0000"  $COLORDIR/$D1

    #Remove green e red  (d2)
    /usr/bin/convert $RAWDIR/$IMG -fuzz 2%  -transparent "#008200" -transparent "#6A0000" $COLORDIR/$D2

    #Remove green E yellow (d3)
    /usr/bin/convert $RAWDIR/$IMG -fuzz 2%  -transparent "#008200" -transparent "$#6A6A00" $COLORDIR/$D3

    gdal_translate -of GTiff -a_ullr -82 12.04 -31.96 -45 -a_srs EPSG:4326 $COLORDIR/$D1  $GEODIR/$D1
    gdal_translate -of GTiff -a_ullr -82 12.04 -31.96 -45 -a_srs EPSG:4326 $COLORDIR/$D2  $GEODIR/$D2
    gdal_translate -of GTiff -a_ullr -82 12.04 -31.96 -45 -a_srs EPSG:4326 $COLORDIR/$D3  $GEODIR/$D3

    #Converte para shpefile
    gdal_polygonize.py $GEODIR/$D1 -f "ESRI Shapefile" $SHPDIR "${IMGNAME}_d1"
    gdal_polygonize.py $GEODIR/$D2 -f "ESRI Shapefile" $SHPDIR "${IMGNAME}_d2"
    gdal_polygonize.py $GEODIR/$D3 -f "ESRI Shapefile" $SHPDIR "${IMGNAME}_d3"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.