Creating square buffers around points using shapely?Geopandas buffer using geodataframe while maintaining the...

Professor forcing me to attend a conference, I can't afford even with 50% funding

Was it really inappropriate to write a pull request for the company I interviewed with?

Is there stress on two letters on the word стоят

Having the player face themselves after the mid-game

How do you make a gun that shoots melee weapons and/or swords?

How is it possible to drive VGA displays at such high pixel clock frequencies?

How do we create new idioms and use them in a novel?

If sound is a longitudinal wave, why can we hear it if our ears aren't aligned with the propagation direction?

Locked Away- What am I?

Computation logic of Partway in TikZ

What is better: yes / no radio, or simple checkbox?

Can I take the the bonus-action attack from Two-Weapon Fighting without taking the Attack action?

Why aren't there more Gauls like Obelix?

Why do phishing e-mails use faked e-mail addresses instead of the real one?

School performs periodic password audits. Is my password compromised?

What does *dead* mean in *What do you mean, dead?*?

Is it a Cyclops number? "Nobody" knows!

Would those living in a "perfect society" not understand satire

Giving a career talk in my old university, how prominently should I tell students my salary?

How to install round brake pads

Use Mercury as quenching liquid for swords?

Why do we say 'Pairwise Disjoint', rather than 'Disjoint'?

Can't make sense of a paragraph from Lovecraft

What is Tony Stark injecting into himself in Iron Man 3?



Creating square buffers around points using shapely?


Geopandas buffer using geodataframe while maintaining the dataframeCreating multiple buffers using QGIS?Creating square buffer around point feature using ArcGIS for Desktop?Shapely LineString and Polygon intersect?Intersect Shapefiles using ShapelyHow to use qgis coordinate transformation in user codeMeasuring roundness using buffers around centroidspoint in polygon starting with csv and shp in pythonCreating polygons for points with different radius in QGISmedMissing 1.6% of expected area after buffering SpatialPoints from vector of widthsCreating buffers around locations when using a Geographic Coordinate System













1















I am trying to create square buffers around given points, I am able to create circular buffers but how do I create square ones?



from shapely.ops import transform
from shapely.geometry import Point
local_azimuthal_projection = "+proj=aeqd +R=6371000 +units=m +lat_0={} +lon_0={}".format(lat, lon)
wgs84_to_aeqd = partial(
pyproj.transform,
pyproj.Proj('+proj=longlat +datum=WGS84 +no_defs'),
pyproj.Proj(local_azimuthal_projection),
)
aeqd_to_wgs84 = partial(
pyproj.transform,
pyproj.Proj(local_azimuthal_projection),
pyproj.Proj('+proj=longlat +datum=WGS84 +no_defs'),
)

point_transformed = transform(wgs84_to_aeqd, Point(float(lon), float(lat)))
buffer = point_transformed.buffer(0.5*1000)
buffered_geom = transform(aeqd_to_wgs84, buffer).exterior.coords[:]









share|improve this question




















  • 1





    Please Edit the question to provide a picture of a "square buffer"

    – Vince
    5 hours ago






  • 1





    As per the Tour there should be only one question asked per question.

    – PolyGeo
    4 hours ago











  • square_buffer = Polygon.from_bounds(*point_transformed.buffer(0.5*1000).bounds)

    – user2856
    1 hour ago
















1















I am trying to create square buffers around given points, I am able to create circular buffers but how do I create square ones?



from shapely.ops import transform
from shapely.geometry import Point
local_azimuthal_projection = "+proj=aeqd +R=6371000 +units=m +lat_0={} +lon_0={}".format(lat, lon)
wgs84_to_aeqd = partial(
pyproj.transform,
pyproj.Proj('+proj=longlat +datum=WGS84 +no_defs'),
pyproj.Proj(local_azimuthal_projection),
)
aeqd_to_wgs84 = partial(
pyproj.transform,
pyproj.Proj(local_azimuthal_projection),
pyproj.Proj('+proj=longlat +datum=WGS84 +no_defs'),
)

point_transformed = transform(wgs84_to_aeqd, Point(float(lon), float(lat)))
buffer = point_transformed.buffer(0.5*1000)
buffered_geom = transform(aeqd_to_wgs84, buffer).exterior.coords[:]









share|improve this question




















  • 1





    Please Edit the question to provide a picture of a "square buffer"

    – Vince
    5 hours ago






  • 1





    As per the Tour there should be only one question asked per question.

    – PolyGeo
    4 hours ago











  • square_buffer = Polygon.from_bounds(*point_transformed.buffer(0.5*1000).bounds)

    – user2856
    1 hour ago














1












1








1








I am trying to create square buffers around given points, I am able to create circular buffers but how do I create square ones?



from shapely.ops import transform
from shapely.geometry import Point
local_azimuthal_projection = "+proj=aeqd +R=6371000 +units=m +lat_0={} +lon_0={}".format(lat, lon)
wgs84_to_aeqd = partial(
pyproj.transform,
pyproj.Proj('+proj=longlat +datum=WGS84 +no_defs'),
pyproj.Proj(local_azimuthal_projection),
)
aeqd_to_wgs84 = partial(
pyproj.transform,
pyproj.Proj(local_azimuthal_projection),
pyproj.Proj('+proj=longlat +datum=WGS84 +no_defs'),
)

point_transformed = transform(wgs84_to_aeqd, Point(float(lon), float(lat)))
buffer = point_transformed.buffer(0.5*1000)
buffered_geom = transform(aeqd_to_wgs84, buffer).exterior.coords[:]









share|improve this question
















I am trying to create square buffers around given points, I am able to create circular buffers but how do I create square ones?



from shapely.ops import transform
from shapely.geometry import Point
local_azimuthal_projection = "+proj=aeqd +R=6371000 +units=m +lat_0={} +lon_0={}".format(lat, lon)
wgs84_to_aeqd = partial(
pyproj.transform,
pyproj.Proj('+proj=longlat +datum=WGS84 +no_defs'),
pyproj.Proj(local_azimuthal_projection),
)
aeqd_to_wgs84 = partial(
pyproj.transform,
pyproj.Proj(local_azimuthal_projection),
pyproj.Proj('+proj=longlat +datum=WGS84 +no_defs'),
)

point_transformed = transform(wgs84_to_aeqd, Point(float(lon), float(lat)))
buffer = point_transformed.buffer(0.5*1000)
buffered_geom = transform(aeqd_to_wgs84, buffer).exterior.coords[:]






python geometry coordinates buffer






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 mins ago









Aaron

38.1k20109254




38.1k20109254










asked 5 hours ago









AtihskaAtihska

1196




1196








  • 1





    Please Edit the question to provide a picture of a "square buffer"

    – Vince
    5 hours ago






  • 1





    As per the Tour there should be only one question asked per question.

    – PolyGeo
    4 hours ago











  • square_buffer = Polygon.from_bounds(*point_transformed.buffer(0.5*1000).bounds)

    – user2856
    1 hour ago














  • 1





    Please Edit the question to provide a picture of a "square buffer"

    – Vince
    5 hours ago






  • 1





    As per the Tour there should be only one question asked per question.

    – PolyGeo
    4 hours ago











  • square_buffer = Polygon.from_bounds(*point_transformed.buffer(0.5*1000).bounds)

    – user2856
    1 hour ago








1




1





Please Edit the question to provide a picture of a "square buffer"

– Vince
5 hours ago





Please Edit the question to provide a picture of a "square buffer"

– Vince
5 hours ago




1




1





As per the Tour there should be only one question asked per question.

– PolyGeo
4 hours ago





As per the Tour there should be only one question asked per question.

– PolyGeo
4 hours ago













square_buffer = Polygon.from_bounds(*point_transformed.buffer(0.5*1000).bounds)

– user2856
1 hour ago





square_buffer = Polygon.from_bounds(*point_transformed.buffer(0.5*1000).bounds)

– user2856
1 hour ago










1 Answer
1






active

oldest

votes


















1














One approach common to many packages is to first apply a circular buffer and then apply an envelope (i.e. smallest rectangular polygon that contains each object).



Here is how you can create square buffers using geopandas GeoSeries.envelope (source):



import pandas as pd
import geopandas as gpd
from shapely.geometry import Point
import matplotlib.pyplot as plt

# Generate some sample data
p1 = Point((1,2))
p2 = Point((5,6))
df = pd.DataFrame({'a': [11,22]})
gdf = gpd.GeoDataFrame(df, geometry = [p1,p2])
gdf.plot()


enter image description here



# Buffer the points by 2 units
buffer = gdf.buffer(2)
buffer.plot()


enter image description here



# Apply an envelope around circular buffers
envelope = buffer.envelope
envelope.plot()


enter image description here





share























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "79"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f314949%2fcreating-square-buffers-around-points-using-shapely%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    One approach common to many packages is to first apply a circular buffer and then apply an envelope (i.e. smallest rectangular polygon that contains each object).



    Here is how you can create square buffers using geopandas GeoSeries.envelope (source):



    import pandas as pd
    import geopandas as gpd
    from shapely.geometry import Point
    import matplotlib.pyplot as plt

    # Generate some sample data
    p1 = Point((1,2))
    p2 = Point((5,6))
    df = pd.DataFrame({'a': [11,22]})
    gdf = gpd.GeoDataFrame(df, geometry = [p1,p2])
    gdf.plot()


    enter image description here



    # Buffer the points by 2 units
    buffer = gdf.buffer(2)
    buffer.plot()


    enter image description here



    # Apply an envelope around circular buffers
    envelope = buffer.envelope
    envelope.plot()


    enter image description here





    share




























      1














      One approach common to many packages is to first apply a circular buffer and then apply an envelope (i.e. smallest rectangular polygon that contains each object).



      Here is how you can create square buffers using geopandas GeoSeries.envelope (source):



      import pandas as pd
      import geopandas as gpd
      from shapely.geometry import Point
      import matplotlib.pyplot as plt

      # Generate some sample data
      p1 = Point((1,2))
      p2 = Point((5,6))
      df = pd.DataFrame({'a': [11,22]})
      gdf = gpd.GeoDataFrame(df, geometry = [p1,p2])
      gdf.plot()


      enter image description here



      # Buffer the points by 2 units
      buffer = gdf.buffer(2)
      buffer.plot()


      enter image description here



      # Apply an envelope around circular buffers
      envelope = buffer.envelope
      envelope.plot()


      enter image description here





      share


























        1












        1








        1







        One approach common to many packages is to first apply a circular buffer and then apply an envelope (i.e. smallest rectangular polygon that contains each object).



        Here is how you can create square buffers using geopandas GeoSeries.envelope (source):



        import pandas as pd
        import geopandas as gpd
        from shapely.geometry import Point
        import matplotlib.pyplot as plt

        # Generate some sample data
        p1 = Point((1,2))
        p2 = Point((5,6))
        df = pd.DataFrame({'a': [11,22]})
        gdf = gpd.GeoDataFrame(df, geometry = [p1,p2])
        gdf.plot()


        enter image description here



        # Buffer the points by 2 units
        buffer = gdf.buffer(2)
        buffer.plot()


        enter image description here



        # Apply an envelope around circular buffers
        envelope = buffer.envelope
        envelope.plot()


        enter image description here





        share













        One approach common to many packages is to first apply a circular buffer and then apply an envelope (i.e. smallest rectangular polygon that contains each object).



        Here is how you can create square buffers using geopandas GeoSeries.envelope (source):



        import pandas as pd
        import geopandas as gpd
        from shapely.geometry import Point
        import matplotlib.pyplot as plt

        # Generate some sample data
        p1 = Point((1,2))
        p2 = Point((5,6))
        df = pd.DataFrame({'a': [11,22]})
        gdf = gpd.GeoDataFrame(df, geometry = [p1,p2])
        gdf.plot()


        enter image description here



        # Buffer the points by 2 units
        buffer = gdf.buffer(2)
        buffer.plot()


        enter image description here



        # Apply an envelope around circular buffers
        envelope = buffer.envelope
        envelope.plot()


        enter image description here






        share











        share


        share










        answered 7 mins ago









        AaronAaron

        38.1k20109254




        38.1k20109254






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f314949%2fcreating-square-buffers-around-points-using-shapely%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Щит и меч (фильм) Содержание Названия серий | Сюжет |...

            Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

            Meter-Bus Содержание Параметры шины | Стандартизация |...