Buffer not accurate

4724
27
12-20-2016 01:16 PM
by Anonymous User
Not applicable

Hi all,

I am trying to buffer a road segment 200' on each side but it seems like the buffer is not returning me anything accurate. The buffer on each side is like 520' as it is now. Maybe wkid?

var extent2 = new Extent({
                    "xmin": -121.11087086999999, "ymin": 38.517479534000074, "xmax": -119.95226375799996, "ymax": 39.068026806000034,
                    "spatialReference": { "wkid": 4326 }
                });

                //Map
                map = new Map("map", {
                    basemap: "topo",
                    extent: extent2
                });


featureLayer.selectFeatures(selectQuery, FeatureLayer.SELECTION_NEW, function (targetGeometry) {
                            targetGeometry = graphicsUtils.getGeometries(featureLayer.getSelectedFeatures());
                            console.log(targetGeometry);
                            geometryService.union(targetGeometry, function (geometry) {
                                featureLayer.clearSelection();
                                //Buffer params
                                var params = new BufferParameters();
                                params.distances = [200];
                                params.unit = geometryService.UNIT_FOOT;
                                //Simplify features first
                                geometryService.simplify([geometry], function (simplifiedGeometries) {
                                    params.geometries = simplifiedGeometries;
                                    //do the buffer
                                    geometryService.buffer(params, showBuffer);
                                });
                            }, function (err) {
                                console.log(err);
                            });
                        });‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
27 Replies
by Anonymous User
Not applicable

Thanks for all your help though Robert. It is really appreciated. few more ideas:

-Maybe measure tool is inaccurate?? I dont think so but I am checking. on the map the measurement tool looks good.

-Maybe the targetgeometry variable graphics do not have any SR

 featureLayer.selectFeatures(selectQuery, FeatureLayer.SELECTION_NEW, function (targetGeometry) {
                            //targetGeometry = graphicsUtils.getGeometries(featureLayer.getSelectedFeatures());

If nothing works, instead of using a feature layer, I will use QueryTask and Query.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

   Was as you do more development you will become accustom to using the developer tools to inspect variables. You can do the basic console.info(targetgeometry); line in your code, or you could place a breakpoint in the code and inspect the var, etc, etc.

0 Kudos
by Anonymous User
Not applicable

It seems like the buffer is returned in meters and not feet. That is what I got from testing

0 Kudos
DarrenWiens2
MVP Alum

So, you get the 200' buffer with: 

params.distances = [60.96];

?

0 Kudos
by Anonymous User
Not applicable

Go the issue, instead of:

params2.unit = geometryService.UNIT_FOOT;

use:

params2.unit = GeometryService.UNIT_FOOT;

 

That was a silly one.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

   Well chalk it up to a learning experience. CaSe matters in programming.

0 Kudos
by Anonymous User
Not applicable

That is definitely a good learning experience right there. I will remember this one... and certainly be more careful about caps letters and lower cases for now on.

0 Kudos
by Anonymous User
Not applicable

yes

0 Kudos