Buffer not accurate

4719
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

Very strange,

When I get rid of the union to test only the buffer I get the following error

current code:

featureLayer.selectFeatures(selectQuery, FeatureLayer.SELECTION_NEW, function (targetGeometry) {
                            targetGeometry = graphicsUtils.getGeometries(featureLayer.getSelectedFeatures());
                            console.log(targetGeometry);
                                featureLayer.clearSelection();
                                //Buffer params
                                var params = new BufferParameters();
                                params.distances = [200];
                                params.unit = geometryService.UNIT_FOOT;
                                params.outSpatialReference = map.spatialReference;
                                params.geodesic = true;
                                geometryService.simplify([targetGeometry], function (simplifiedGeometries) {
                                    params.geometries = simplifiedGeometries;
                                    //do the buffer
                                    geometryService.buffer(params, showBuffer);
                                });
                        });
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

   If you do not union the selected geometries then you are you are passing an array of an array of geometries to the simplify.

geometryService.simplify([targetGeometry], function (simplifiedGeometries) {

targetGeomtry is an array then you wrap it in an array by doing this: [targetGeometry]

0 Kudos
by Anonymous User
Not applicable

That is right. Ok, I am not too sure what I am missing on my buffer. Is the

simplify output line projected correctly and then messes up my buffer? I am

running out of idea.

On Tue, Dec 20, 2016 at 4:55 PM, Robert Scheitlin, GISP <geonet@esri.com>

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

    What is the wkid of the lines that are selected.

0 Kudos
by Anonymous User
Not applicable

Lines that are buffered are from road layer ID 3. spatial reference is as

here:

I am using the simplified geometry as param input for buffer as shown below:

feature that I select:

featureLayer = new FeatureLayer("

http://itas46:6080/arcgis/rest/services/Alex_test/TreemortalityAllLayers/MapServer/3

",

);

featureLayer.setAutoGeneralize(false);

featureLayer.setMaxAllowableOffset(0);

//simplify

geometryService.simplify(, function (simplifiedGeometries) {

params2.geometries =

simplifiedGeometries;

//do the buffer

geometryService.buffer(params2,

showBuffer);

});

On Tue, Dec 20, 2016 at 5:40 PM, Robert Scheitlin, GISP <geonet@esri.com>

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

   So did you try adding the

params.bufferSpatialReference = new SpatialReference({wkid:102003});

and not doing the union?

0 Kudos
by Anonymous User
Not applicable

Yes, I tried. Same results.

current code:

 featureLayer.selectFeatures(selectQuery, FeatureLayer.SELECTION_NEW, function (targetGeometry) {
                            targetGeometry = graphicsUtils.getGeometries(featureLayer.getSelectedFeatures());
                            console.log(targetGeometry);
                            //geometryService.union(targetGeometry, function (geometry) {
                                featureLayer.clearSelection();
                                //Params buffer
                                var params2 = new BufferParameters();
                                params2.distances = [200];
                                params2.unit = geometryService.UNIT_FOOT;
                                params2.outSpatialReference = map.spatialReference;
                                params2.bufferSpatialReference = new SpatialReference({ wkid: 102100, latestWkid: 3857 });
                                params2.geodesic = true;
                                geometryService.simplify(targetGeometry, function (simplifiedGeometries) {
                                    params2.geometries = simplifiedGeometries;
                                    //do the buffer
                                    geometryService.buffer(params2, showBuffer);
                                });
                            //}, function (err) {
                            //    console.log(err);
                            //});
                        });
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

   Ok I am seeing this:

params2.bufferSpatialReference = new SpatialReference({ wkid: 102100, latestWkid: 3857 });

instead of what I recommended:

params.bufferSpatialReference = new SpatialReference({wkid:102003});
0 Kudos
by Anonymous User
Not applicable

Ah ok. I just tried without success.

current code:

featureLayer.selectFeatures(selectQuery, FeatureLayer.SELECTION_NEW, function (targetGeometry) {
                            targetGeometry = graphicsUtils.getGeometries(featureLayer.getSelectedFeatures());
                            console.log(targetGeometry);
                            //geometryService.union(targetGeometry, function (geometry) {
                                featureLayer.clearSelection();
                                //Params buffer
                                var params2 = new BufferParameters();
                                params2.distances = [200];
                                params2.unit = geometryService.UNIT_FOOT;
                                params2.outSpatialReference = map.spatialReference;
                                params2.bufferSpatialReference = new SpatialReference({ wkid: 102003 });
                                params2.geodesic = true;
                                geometryService.simplify(targetGeometry, function (simplifiedGeometries) {
                                    params2.geometries = simplifiedGeometries;
                                    //do the buffer
                                    geometryService.buffer(params2, showBuffer);
                                });
                            //}, function (err) {
                            //    console.log(err);
                            //});
                        });
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

   Well I am running out of ideas then.

0 Kudos