|
POST
|
I have two geodataframes that I want to perform a spatial join on; one is points, one is polygons. They are both dtype: int64 . They both have .crs = {'init': 'epsg:4326'} . I have verified both of them in ArcMap that the points are indeed within the polys. I even performed an intersect between these points and polygons in ArcMap and it produced the correct new feature class (I have reasons for wanting to do this without arpy /manually in ArcMap). **Note: the points are from a shapefile and the polys are from a feature class However, when I turn my centroid points and parcel polygons into geodataframes and use .sjoin() , it returns an empty geodataframe . I want the output to be a point-based geometry so that I can eventually turn it back into a point shapefile. I have tried: intersect_test = gpd.sjoin(cents, polys, how='left', op='intersects') and intersect_test = gpd.sjoin(polys, cents, how='inner', op='intersects') and intersect_test = gpd.sjoin(polys, cents, how='right', op='intersects') and intersect_test = gpd.sjoin(cents, polys, how='left', op='intersects') and pretty much every other configuration I can think of and it either returns the data for one of them, or returns a completely empty geodataframe result. intersect_test = gpd.sjoin(cents, polys, how='inner', op='intersects') intersect_test.count()Out[126]: BLD_UNITS 0LAND_USE_T 0PARCEL_ID 0PROP_IND_T 0STORY_NBR 0geometry 0index_right 0GEOID 0CensusPop 0CBArea 0ST_FIPS 0Shape_Length 0Shape_Area 0CO_FIPS 0HU_Pop 0Sq_Ft 0dtype: int64 How can I resolve this without having to manually perform the intersect in ArcMap? EDIT Here's how I made my geodataframes . As I mentioned; one is a shapefile and one is a .gdb feature class . Question: Could this be due to projection/ crs -related problem? #create poly gdfcb_gdb = r"C:\Projects\Pop_Alloc\CensusBlocksStates.gdb"cb_feat = "CBs_{}".format(state)cents = gpd.read_file(cb_gdb, layer=cb_feat)cents.crs = {'init': 'epsg:4326'}#create point gdf. The parcel centroids are first created from a polygon gdf. The new gdf is written to a shapefile to be tested against the census block polygons (to make sure they do in fact fall within the boundaries of the census blocks (cbs)) and the new centroid gdf(its a `type='geopandas.geodataframe.GeoDataFrame'`) is then used in the `.sjoin` cents = parcel_res_df cents['geometry'] = cents['geometry'].representative_point()cents_out_feat = r"C:\Projects\Pop_Alloc\{}_Res_centroids.shp".format(state)cents.crs = {'init': 'epsg:4326'}cents.to_file(cents_out_feat)
... View more
07-08-2019
10:52 AM
|
0
|
0
|
2214
|
|
POST
|
This issue was resolved by doing a few simple things that were not obvious at a glance. First, there is a CORS issue using this method. Unfortunately, the errors I was receiving in the browser console did not clue me into this and I discovered it by accident (I am using another esriRequest in the script that required this fix). I simply added the following code at the top after listing my required functions: esriConfig.defaults.io.corsEnabledServers.push("api-hazards.atcouncil.org"); // supports CORS I also refactored my callBack function to include the .indexOf method as in the documentation: function myCallbackFunction(ioArgs){ if (ioArgs.url.indexOf("https://api-hazards.atcouncil.org") > -1) { ioArgs.headers = ioArgs.headers || {}; // make sure headers are not null ioArgs.headers["Api-Key"] = "<123mykey>" // add custom headers } return ioArgs; } Finally, I had to add the .setRequestPreCallback call before the button click, not inside it (even if it is before the actual esriRequest. callbackParamName: "callback" also had to be removed. These changes were slight, but absolutely crucial to making this work. I am a little frustrated that the documentation does not contain clearer instructions on applying headers and keys to an esriRequest. This is a common task for anyone using a 3rd party API and there are no practical examples (or mentions of potentials issues like the CORS problem) to illustrate the correct application. esriRequest.setRequestPreCallback(myCallbackFunction); //Get Wind Speed Data button click function document.getElementById("btnGetWindspeed").onclick = function () { if (additionalInfo["pointGeomOfInterest"] !== undefined) { var lat = additionalInfo["pointGeomOfInterest"].y; var long = additionalInfo["pointGeomOfInterest"].x; } if (additionalInfo["pointGeomOfInterest"] === undefined) { alert("Choose a location!"); } else { var base_url = wind_url + "wind.json"; var lat = additionalInfo["pointGeomOfInterest"].y; var long = additionalInfo["pointGeomOfInterest"].x; var windRequest = esriRequest({ url: base_url, content: { "lat": lat, "lng": long }, dataType:"jsonp", handleAs: "json" });
... View more
07-08-2019
06:32 AM
|
1
|
1
|
3537
|
|
POST
|
I want to add an api-key to the header of my esriRequest. I first created a callback function. function myCallbackFunction(ioArgs){ ioArgs.headers = ioArgs.headers || {}; // make sure headers are not null ioArgs.headers["api-key"] = "<123mykey>" // add custom headers return ioArgs; } My esriRequest is triggered by a button click after the lat, long have been captured. I placed by .setRequestPreCallback() that calls my myCallbackFunction right before the request is made, inside the click event. wind_url = "https://api-hazards.atcouncil.org/public/v1/"; document.getElementById("btnGetWindspeed").onclick = function () { if (additionalInfo["pointGeomOfInterest"] !== undefined) { var lat = additionalInfo["pointGeomOfInterest"].y; var long = additionalInfo["pointGeomOfInterest"].x; } if (additionalInfo["pointGeomOfInterest"] === undefined) { alert("Choose a location!"); } else { var base_url = wind_url + "wind.json"; var lat = additionalInfo["pointGeomOfInterest"].y; var long = additionalInfo["pointGeomOfInterest"].x; esriRequest.setRequestPreCallback(myCallbackFunction); var windRequest = esriRequest({ url: base_url, content: { "lat": lat, "lng": long }, dataType:"jsonp", handleAs: "json", callbackParamName: "callback" }); windRequest.then( function(response) { wind_data = response.response.data; console.log("Success: ", wind_data); addWindspeedTable(wind_data); }, function(error) { console.log("Error: ", error.message); }); }; However, the callback function fails and I get the following error that the api has not been authorized: `Failed to load resource: the server responded with a status of 401 (Unauthorized)`. Am I adding the headers incorrectly, utilizing the .setRequestPreCallback() wrong, or is something else going on? Note: I have validated the api key and url in Postman and gotten a correct response.
... View more
07-02-2019
12:05 PM
|
0
|
2
|
4175
|
|
POST
|
OK, I am trying to apply setRequestPreCallback to my situation based on the documentation. First, created a function: function myCallbackFunction(ioArgs){ if (ioArgs.url.indexOf("https://api-hazards.atcouncil.org") > -1) { ioArgs.headers = ioArgs.headers || {}; // make sure headers are not null ioArgs.headers["api-key"] = " xI234fg543example23 " // add custom headers } return ioArgs; } Then I tried calling the function before I make my esriRequest (which is inside a button click event). var seis_data; //Get Seismic Data button click function document.getElementById("btnGetSeismic").onclick = function () { if (additionalInfo["pointGeomOfInterest"] !== undefined) { var lat = additionalInfo["pointGeomOfInterest"].y; var long = additionalInfo["pointGeomOfInterest"].x; } if (risk == "" || siteClass == "" || reference == "" || additionalInfo["pointGeomOfInterest"] === undefined) { alert("Choose a Reference, Risk Category, Site Class, and location!"); } else if (siteClass == "F") { alert("Site class F temporarily unavaliable. Please select an alternate site class and consult the ASCE/SEI 7-16 reference document for more information on the seismic design parameters for Site Class F - Site Response Analysis."); } else { var base_url = seismic_url + reference + ".json"; var lat = additionalInfo["pointGeomOfInterest"].y; var long = additionalInfo["pointGeomOfInterest"].x; esriRequest.setRequestPreCallback(myCallbackFunction); var layersRequest = esriRequest({ url: base_url, content: { "latitude": lat, "longitude": long, "riskCategory": risk, "siteClass": siteClass, "title":"Default"}, dataType:'jsonp', handleAs: "json", callbackParamName: "callback" }); layersRequest.then( function(response) { seis_data = response.response.data; console.log("Success: ", seis_data); // populate_table(); addSeismicTable(seis_data); populateAddSeismicTableResults(seis_data); }, function(error) { console.log("Error: ", error.message); }); }; } Right now I am getting a net::ERR_ABORTED 401 (Unauthorized) error. I tested the API Key in Postman and it worked. Do you see anything I am doing incorrectly in applying this?
... View more
07-01-2019
10:25 AM
|
0
|
0
|
3035
|
|
POST
|
I have been making calls to a previously free API using esriRequest var layersRequest = esriRequest({
url: base_url,
content: {
"latitude": lat,
"longitude": long,
"riskCategory": risk,
"siteClass": siteClass,
"title":"Default"},
dataType:'jsonp',
handleAs: "json",
callbackParamName: "callback" }); ... Now the API requires a key; which I have: const key = 'xI234fg543example23'; The above is just an **example key; not real The API documentation says to "Include your key in the api-key field of your request headers to authenticate like this: curl --header "api-key: [your_api_key]" -X GET "https://api-hazards.atcouncil.org/public/v1/[load_category].json?lat=[lat]&lng=[lng]" How do I correctly apply this using esriRequest ? I believe the generic javascript equivalent would be layerRequest.setRequestHeader
... View more
07-01-2019
08:18 AM
|
0
|
4
|
3449
|
|
POST
|
OK, fixed it (I think). When I launched it this time, I got `Success: {pgauh: 0.383, pgad: 1798.2, pga: 0.383, fpga: 1.217, pgam: 0.466, …}` showing in the console. So I get an Object. But if I try typing `console.log(layersRequest)' in the console, it's still saying its not defined. I don't get it! What I want to do now is pull out the value for s1 from the object into a variable that I will later display in the dom in a table. I thought I could test this out in my console first; not sure what's wrong.
... View more
05-23-2019
08:16 AM
|
0
|
1
|
5305
|
|
POST
|
Ugh, OK, it is actually not working. I resolved the CORS issue but now I am seeing that `layerRequest` is not defined! Assuming I am going to continue with 3.x, is there something I need to change in my require calls and corresponding functions?
... View more
05-23-2019
07:37 AM
|
0
|
3
|
5305
|
|
POST
|
OK, that seemed to resolve the initial issue! Thanks so much Robert. Follow up question though; I am now getting the old "Cross-Origin Read Blocking (CORB) blocked cross-origin response ...<url> ... with MIME type application/json" error. From looking at a few related post, it seems this is cause by the server sending back a jsonp response or something? Is there an easy way to resolve this inside the code?
... View more
05-23-2019
07:26 AM
|
0
|
1
|
5305
|
|
POST
|
Sorry, I am refactoring some of this code from another application. I believe it is 3x not 4.1. Could this be part of the problem? The map displays properly when I remove the esriRequest call at the bottom, but I am wondering if some of the other libraries/modules I am using are causing the issue. I tried moving esri/request and esriRequest to the top, but it didn't seem to make a difference.
... View more
05-23-2019
05:51 AM
|
0
|
2
|
5305
|
|
POST
|
I am trying to use esri/request to pull in some data from an API. I am have two weird problems. First, when I try to run this, it doesn't complete and throws the following error in the browser console: "Uncaught TypeError: Cannot read property 'trim' of undefined". I am not using trim() anywhere and am not sure why this error is being thrown (specifically on the line where I make my esriRequest ). Second, if I try to test this in the browser by pasting in the function to the console, it says that esriRequest is not defined. I have checked the order of my required list and functions several times and they look like they are in the proper order. Am I missing something here? require([
"esri/map",
"esri/basemaps",
"esri/dijit/BasemapToggle",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/tasks/ImageServiceIdentifyTask",
"esri/tasks/ImageServiceIdentifyParameters",
"esri/layers/WebTiledLayer",
"esri/dijit/Search",
"esri/config",
"esri/request",
"dojo/json",
"dojo/promise/all",
"dojo/domReady!"], function(
Map,
esriBasemaps,
BasemapToggle,
ArcGISDynamicMapServiceLayer,
ImageServiceIdentifyTask,
ImageServiceIdentifyParameters,
WebTiledLayer,
Search,
esriConfig,
esriRequest,
JSON,
all) {
.....
var url = "https://earthquake.usgs.gov/ws/designmaps/asce7-16.json?latitude=18&longitude=-66&riskCategory=I&siteClass=D&title=Default";
esriRequest(url, {
responseType: "json"
}).then(function(response){
// The requested data
var seis_data = response.data;
});
... View more
05-23-2019
05:26 AM
|
0
|
10
|
6849
|
|
POST
|
Hey all, My IT support doesn't have the arcObjects folder that came bundled with my ArcGIS Desktop10.5 (where the ArcGIS SDK for .NET should live). I am trying to download the SDK through ESRI but I am not sure what version of the SDK to get. Does SDK version 10.5.1 work for ArcGIS Desktop version 10.5?
... View more
02-01-2019
01:20 PM
|
0
|
0
|
510
|
|
POST
|
OK, that makes sense (I think; I am totally new to this). By the way, do you know of any tutorials or documentation that show how to create an add on for ArcGIS Desktop (not Pro) using Visual Studio/ .NET? Everything out there on the ESRI sight is geared towards Pro.
... View more
01-11-2019
02:13 PM
|
0
|
1
|
2142
|
|
POST
|
I am trying to install the ArcGIS Runtime SDK for .NET using Visual Studio 2015 (I see that it is not supported yet for VS 2017, so I installed 2015). I downloaded and installed the Runtime SDK (100.30). I am not seeing any of the Esri/ArcGIS templates under projects so I opened an existing solution; an AddIn, and tried using nuGet to download the package. I got the following error: "Could not install package Esri.ArcGISRuntime 100.30. You are trying to install this package into a project that targets '.NETFramework, Version=v3.5' but the package does not contain any assembly references or content files that are compatible with that framework." What am I doing wrong here?
... View more
01-11-2019
01:49 PM
|
0
|
3
|
2987
|
|
POST
|
Hey - I think, because of the structure and dependencies in the application I am trying to modify, I am going with the esri/dijit/InfoWindow. My main problem is that the example used is not working. I think this will work, but it may take some trail and error.
... View more
01-07-2019
01:12 PM
|
0
|
0
|
1686
|
|
POST
|
I am trying to find a general raster widget to use in a custom Web AppBuilder app, but I am not seeing anything out of the box. I basically just need a widget to plug into the app that would display just raster layer. My goal is to then select a raster layer from the dialog window and be able to click or mouse over that layer and have info displayed as a popup about that raster layer. My question are 1) Are there any out of the box raster widgets that fit the bill and/or 2) Any suggestions for a custom widget that would work? I am checking custom widgets from /blogs/myAlaskaGIS/2017/03/04/web-appbuilder-the-custom-widgets-list-332017 , but not seeing anything popout.
... View more
12-31-2018
07:36 AM
|
0
|
3
|
2350
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-19-2021 01:41 PM | |
| 1 | 11-05-2019 07:44 AM | |
| 1 | 11-05-2019 09:58 AM | |
| 1 | 01-06-2021 05:41 AM | |
| 1 | 12-24-2020 06:48 AM |
| Online Status |
Offline
|
| Date Last Visited |
03-19-2022
10:13 PM
|