Giter Site home page Giter Site logo

bjnortier / crop-satellite-tiles-to-geojson Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 4.99 MB

Repo for my blogpost on cropping tiles satellite imagery to a GeoJSON boundary

Home Page: https://bjnortier.com/blog/cropping-tiled-satellite-imagery

License: MIT License

Python 100.00%

crop-satellite-tiles-to-geojson's People

Stargazers

 avatar

Watchers

 avatar

crop-satellite-tiles-to-geojson's Issues

Solve RGB in one step

# How to do RGB in one step?

Use .polygon(fill=255) to draw the alpha mask with a 255 value
and later just merge the single sliced layer in masked_raw[...,3] = mask_raw

def mask_pixels_outside_boundary(cropped_to_boundary_image,
                                 boundary_coordinates,
                                 cropped_bbox):
    """
    Mask the image to only include pixels inside the GeoJSON boundary.
    """
    polygon_pixels = create_boundary_pixels(
        boundary_coordinates,
        cropped_bbox,
        cropped_to_boundary_image.size)
    mask_image = Image.new('L', cropped_to_boundary_image.size, 0)
    ImageDraw.Draw(mask_image).polygon(polygon_pixels, outline=0, fill=255)
    mask_raw = np.array(mask_image)

    cropped_to_bbox_raw = np.asarray(cropped_to_boundary_image)
    masked_raw = np.empty(cropped_to_bbox_raw.shape, dtype='uint8')
    masked_raw[...,3] = mask_raw
    masked_image = Image.fromarray(masked_raw, 'RGBA')
    return masked_image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.