How do I get the population by country when using the Esri Demographics Geoprocessing Service?How to navigate...

What did Putin say about a US deep state in his state-of-the-nation speech; what has he said in the past?

Was the Soviet N1 really capable of sending 9.6 GB/s of telemetry?

How many copper coins fit inside a cubic foot?

Are all power cords made equal?

Why is Bernie Sanders maximum accepted donation on actblue $5600?

Isn't a semicolon (';') needed after a function declaration in C++?

Empty optional argument or Not giving optional argument at all?

Use intersection in field calculator

How can changes in personality/values of a person who turned into a vampire be explained?

How should I ship cards?

How do I avoid the "chosen hero" feeling?

Is corrosion inhibitor paste conductive?

Why do we divide Permutations to get to Combinations?

Last Reboot commands don't agree

The Longest Chess Game

How do I know my password or backup information is not being shared when creating a new wallet?

Which part is the tail in 人参{にんじん}の尻尾{しっぽ}

Exploding Numbers

Aligning Systems of Equations

How can I use a Module anonymously as the function for /@?

Cryptic cross... with words

Smallest possible mole

How do I split ammo?

Build ASCII Podiums



How do I get the population by country when using the Esri Demographics Geoprocessing Service?


How to navigate the REST endpoints and retrieve Field information programaticallyAbout proxy in javascript apiESRI geoprocessing service with Javascript API 3.5What is correct entry to Input Location (GPFeatureRecordSetLayer)*?How to get/pass token with ajax call to secured ArcGIS REST ServiceHow to avoid Cross Origin problem when trying to use ArcGIS Online Geocode server?ArcGIS API for JavaScript QueryTask for user's own mapArcGIS Javascript Legend widget does not show full color rampArcGIS JavaScript API: SEC7127: Redirect was blocked for CORS request after submitting geoprocessing jobStuck on getting proxy to work













0















I am using the ArcGIS JavaScript API and Geoprocessing Services to get population. The service takes an input circle and returns the population inside.



Some times, a circle can cover cover more than one country (for example Spain and Portugal) but I need to get the population of a single country using a filter.



I am using this function to get the area using Google Maps:



function getPop()
myFunctions.ftn_findpop1(selectedShape.center.lat(),selectedShape.center.lng(),selectedShape.getRadius());
}
Then...
function findPop(ring) {
var gp = new esri.tasks.Geoprocessor("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/GPServer/PopulationSummary");
...









share|improve this question
















bumped to the homepage by Community 30 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • What precisely have you tried so far? Are you doing this using ArcObjects, ArcPy or another part of the Geoprocessing Framework?

    – PolyGeo
    Jan 18 at 21:25











  • Cross-posted as stackoverflow.com/q/54238580/820534

    – PolyGeo
    Jan 19 at 12:18











  • Thank you very much for your answers. Let me be more clear: I am getting an area with this : function ... () { ....(selectedShape.center.lat(),selectedShape.center.lng(),selectedShape.getRadius()} And then... { var gp = new esri.tasks.Geoprocessor("sampleserver1.arcgisonline.com/ArcGIS/rest/services/…); ... to get the total population. The problem is that some times, the circle can cover more than one country and I need to get the results by country. Does it make sense? Thank you very much!

    – Roger Peñarroya i Zaldívar
    Jan 22 at 12:21













  • I can't add an answer as the question is currently locked, but I'll caution a couple things. 1) This is a sample service, I wouldn't take it as being authoritative. 2) The data in this service is probably 5+ years old 3) Population counts have been interpolated to a raster dataset. I think that raster had a cell size of 250, perhaps even 1000km. It's very, very coarse. Clipping population size to actual country boundaries isn't going to be very accurate. If you're "ok" with what I'd call rough population estimates, this service would be ok to use.

    – KHibma
    Jan 22 at 13:46











  • Actually you can see the source data in a map service here: https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer -- the cell size looks to be about 4km x 4km. So it might not be as bad as I thought

    – KHibma
    Jan 22 at 13:50
















0















I am using the ArcGIS JavaScript API and Geoprocessing Services to get population. The service takes an input circle and returns the population inside.



Some times, a circle can cover cover more than one country (for example Spain and Portugal) but I need to get the population of a single country using a filter.



I am using this function to get the area using Google Maps:



function getPop()
myFunctions.ftn_findpop1(selectedShape.center.lat(),selectedShape.center.lng(),selectedShape.getRadius());
}
Then...
function findPop(ring) {
var gp = new esri.tasks.Geoprocessor("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/GPServer/PopulationSummary");
...









share|improve this question
















bumped to the homepage by Community 30 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • What precisely have you tried so far? Are you doing this using ArcObjects, ArcPy or another part of the Geoprocessing Framework?

    – PolyGeo
    Jan 18 at 21:25











  • Cross-posted as stackoverflow.com/q/54238580/820534

    – PolyGeo
    Jan 19 at 12:18











  • Thank you very much for your answers. Let me be more clear: I am getting an area with this : function ... () { ....(selectedShape.center.lat(),selectedShape.center.lng(),selectedShape.getRadius()} And then... { var gp = new esri.tasks.Geoprocessor("sampleserver1.arcgisonline.com/ArcGIS/rest/services/…); ... to get the total population. The problem is that some times, the circle can cover more than one country and I need to get the results by country. Does it make sense? Thank you very much!

    – Roger Peñarroya i Zaldívar
    Jan 22 at 12:21













  • I can't add an answer as the question is currently locked, but I'll caution a couple things. 1) This is a sample service, I wouldn't take it as being authoritative. 2) The data in this service is probably 5+ years old 3) Population counts have been interpolated to a raster dataset. I think that raster had a cell size of 250, perhaps even 1000km. It's very, very coarse. Clipping population size to actual country boundaries isn't going to be very accurate. If you're "ok" with what I'd call rough population estimates, this service would be ok to use.

    – KHibma
    Jan 22 at 13:46











  • Actually you can see the source data in a map service here: https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer -- the cell size looks to be about 4km x 4km. So it might not be as bad as I thought

    – KHibma
    Jan 22 at 13:50














0












0








0








I am using the ArcGIS JavaScript API and Geoprocessing Services to get population. The service takes an input circle and returns the population inside.



Some times, a circle can cover cover more than one country (for example Spain and Portugal) but I need to get the population of a single country using a filter.



I am using this function to get the area using Google Maps:



function getPop()
myFunctions.ftn_findpop1(selectedShape.center.lat(),selectedShape.center.lng(),selectedShape.getRadius());
}
Then...
function findPop(ring) {
var gp = new esri.tasks.Geoprocessor("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/GPServer/PopulationSummary");
...









share|improve this question
















I am using the ArcGIS JavaScript API and Geoprocessing Services to get population. The service takes an input circle and returns the population inside.



Some times, a circle can cover cover more than one country (for example Spain and Portugal) but I need to get the population of a single country using a filter.



I am using this function to get the area using Google Maps:



function getPop()
myFunctions.ftn_findpop1(selectedShape.center.lat(),selectedShape.center.lng(),selectedShape.getRadius());
}
Then...
function findPop(ring) {
var gp = new esri.tasks.Geoprocessor("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/GPServer/PopulationSummary");
...






arcgis-10.2 arcgis-javascript-api geoprocessing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 22 at 13:43









KHibma

10.2k11839




10.2k11839










asked Jan 18 at 19:26









Roger Peñarroya i ZaldívarRoger Peñarroya i Zaldívar

11




11





bumped to the homepage by Community 30 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 30 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • What precisely have you tried so far? Are you doing this using ArcObjects, ArcPy or another part of the Geoprocessing Framework?

    – PolyGeo
    Jan 18 at 21:25











  • Cross-posted as stackoverflow.com/q/54238580/820534

    – PolyGeo
    Jan 19 at 12:18











  • Thank you very much for your answers. Let me be more clear: I am getting an area with this : function ... () { ....(selectedShape.center.lat(),selectedShape.center.lng(),selectedShape.getRadius()} And then... { var gp = new esri.tasks.Geoprocessor("sampleserver1.arcgisonline.com/ArcGIS/rest/services/…); ... to get the total population. The problem is that some times, the circle can cover more than one country and I need to get the results by country. Does it make sense? Thank you very much!

    – Roger Peñarroya i Zaldívar
    Jan 22 at 12:21













  • I can't add an answer as the question is currently locked, but I'll caution a couple things. 1) This is a sample service, I wouldn't take it as being authoritative. 2) The data in this service is probably 5+ years old 3) Population counts have been interpolated to a raster dataset. I think that raster had a cell size of 250, perhaps even 1000km. It's very, very coarse. Clipping population size to actual country boundaries isn't going to be very accurate. If you're "ok" with what I'd call rough population estimates, this service would be ok to use.

    – KHibma
    Jan 22 at 13:46











  • Actually you can see the source data in a map service here: https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer -- the cell size looks to be about 4km x 4km. So it might not be as bad as I thought

    – KHibma
    Jan 22 at 13:50



















  • What precisely have you tried so far? Are you doing this using ArcObjects, ArcPy or another part of the Geoprocessing Framework?

    – PolyGeo
    Jan 18 at 21:25











  • Cross-posted as stackoverflow.com/q/54238580/820534

    – PolyGeo
    Jan 19 at 12:18











  • Thank you very much for your answers. Let me be more clear: I am getting an area with this : function ... () { ....(selectedShape.center.lat(),selectedShape.center.lng(),selectedShape.getRadius()} And then... { var gp = new esri.tasks.Geoprocessor("sampleserver1.arcgisonline.com/ArcGIS/rest/services/…); ... to get the total population. The problem is that some times, the circle can cover more than one country and I need to get the results by country. Does it make sense? Thank you very much!

    – Roger Peñarroya i Zaldívar
    Jan 22 at 12:21













  • I can't add an answer as the question is currently locked, but I'll caution a couple things. 1) This is a sample service, I wouldn't take it as being authoritative. 2) The data in this service is probably 5+ years old 3) Population counts have been interpolated to a raster dataset. I think that raster had a cell size of 250, perhaps even 1000km. It's very, very coarse. Clipping population size to actual country boundaries isn't going to be very accurate. If you're "ok" with what I'd call rough population estimates, this service would be ok to use.

    – KHibma
    Jan 22 at 13:46











  • Actually you can see the source data in a map service here: https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer -- the cell size looks to be about 4km x 4km. So it might not be as bad as I thought

    – KHibma
    Jan 22 at 13:50

















What precisely have you tried so far? Are you doing this using ArcObjects, ArcPy or another part of the Geoprocessing Framework?

– PolyGeo
Jan 18 at 21:25





What precisely have you tried so far? Are you doing this using ArcObjects, ArcPy or another part of the Geoprocessing Framework?

– PolyGeo
Jan 18 at 21:25













Cross-posted as stackoverflow.com/q/54238580/820534

– PolyGeo
Jan 19 at 12:18





Cross-posted as stackoverflow.com/q/54238580/820534

– PolyGeo
Jan 19 at 12:18













Thank you very much for your answers. Let me be more clear: I am getting an area with this : function ... () { ....(selectedShape.center.lat(),selectedShape.center.lng(),selectedShape.getRadius()} And then... { var gp = new esri.tasks.Geoprocessor("sampleserver1.arcgisonline.com/ArcGIS/rest/services/…); ... to get the total population. The problem is that some times, the circle can cover more than one country and I need to get the results by country. Does it make sense? Thank you very much!

– Roger Peñarroya i Zaldívar
Jan 22 at 12:21







Thank you very much for your answers. Let me be more clear: I am getting an area with this : function ... () { ....(selectedShape.center.lat(),selectedShape.center.lng(),selectedShape.getRadius()} And then... { var gp = new esri.tasks.Geoprocessor("sampleserver1.arcgisonline.com/ArcGIS/rest/services/…); ... to get the total population. The problem is that some times, the circle can cover more than one country and I need to get the results by country. Does it make sense? Thank you very much!

– Roger Peñarroya i Zaldívar
Jan 22 at 12:21















I can't add an answer as the question is currently locked, but I'll caution a couple things. 1) This is a sample service, I wouldn't take it as being authoritative. 2) The data in this service is probably 5+ years old 3) Population counts have been interpolated to a raster dataset. I think that raster had a cell size of 250, perhaps even 1000km. It's very, very coarse. Clipping population size to actual country boundaries isn't going to be very accurate. If you're "ok" with what I'd call rough population estimates, this service would be ok to use.

– KHibma
Jan 22 at 13:46





I can't add an answer as the question is currently locked, but I'll caution a couple things. 1) This is a sample service, I wouldn't take it as being authoritative. 2) The data in this service is probably 5+ years old 3) Population counts have been interpolated to a raster dataset. I think that raster had a cell size of 250, perhaps even 1000km. It's very, very coarse. Clipping population size to actual country boundaries isn't going to be very accurate. If you're "ok" with what I'd call rough population estimates, this service would be ok to use.

– KHibma
Jan 22 at 13:46













Actually you can see the source data in a map service here: https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer -- the cell size looks to be about 4km x 4km. So it might not be as bad as I thought

– KHibma
Jan 22 at 13:50





Actually you can see the source data in a map service here: https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer -- the cell size looks to be about 4km x 4km. So it might not be as bad as I thought

– KHibma
Jan 22 at 13:50










1 Answer
1






active

oldest

votes


















0














I'm excluding the part where you're referencing Google Maps. I'm not entirely sure how that comes into play with this question.



Essentially you need to find the geometry of a country, with that you can pass that geometry into the geoprocessing service and have it use that instead of a "circle". Luckily there is a lot of data to be found on ArcGIS.com, including country boundaries.



The below code is very close to what you want to do. (It might actually work, but sampleserver1 is giving me CORS Cross domain issues and I'm not in a position to setup a proxy to make a good request. (My issue is beyond the scope of your initial question.) Below you can see that a button press starts everything. Pressing the button sets a definition express for Country = Spain. (there are many different ways to perform a query). The selected featurelayer with the definition is sent as input to the geoprocessing service. You'll get back a response and the app is responsible for popping up a text box with the output.



Remember, the code below will probably not just run, but it shows the pattern you need to undertake.



Note - pieced together from GP Zonal Stats and other feature layer samples.



<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<link rel="stylesheet" href="https://js.arcgis.com/3.27/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.27/esri/css/esri.css" />
<script src="https://js.arcgis.com/3.27/"></script>
<script>
var map;

require([
"esri/map",
"esri/layers/FeatureLayer",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/tasks/Geoprocessor",
"dojo/dom",
"dojo/on",
"dojo/parser",
"dojo/string",
"esri/Color",
"dijit/registry",
"dijit/form/Button",
"dojo/domReady!"
],
function (Map, FeatureLayer, SimpleFillSymbol, SimpleLineSymbol,
Geoprocessor, dom, on, parser, string, Color, registry
) {

parser.parse();

var featureLayer, map;

map = new Map("map", {
basemap: "streets",
center: [0, 0],
zoom: 3
});
gp = new Geoprocessor("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/GPServer/PopulationSummary");
gp.setOutputSpatialReference({wkid:102100});
gp.on("execute-complete", displayResults);


var fieldsSelectionSymbol =
new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.5]));
// country boundary polygons
featureLayer = new FeatureLayer("http://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Countries_(Generalized)/FeatureServer/0",
{
mode: FeatureLayer.MODE_ONDEMAND,
outFields: ["*"]
});
featureLayer.setSelectionSymbol(fieldsSelectionSymbol);
map.addLayer(featureLayer);

function computeZonalStats() {
featureLayer.setDefinitionExpression("Country ='Spain'");
var params = { "inputPoly":featureLayer };
gp.execute(params);
}

function displayResults(evtObj) {
console.log(evtObj);
var results = evtObj.results;
var content = string.substitute("<h4>The population in the user defined polygon is ${number:dojo.number.format}.</h4>",{number:results[0].value.features[0].attributes.SUM});

registry.byId("dialog1").setContent(content);
registry.byId("dialog1").show();
}
app = {
computeZonalStats: computeZonalStats
};

});
</script>
</head>

<body class="claro">
<button id="querySpainButton" data-dojo-type="dijit/form/Button" onclick="app.computeZonalStats()">Query Spain</button>
<div id="map" style="position: relative; width:700px; height:500px; border:1px solid #000;"></div>
<div data-dojo-type="dijit.Dialog" id="dialog1" title="Population Summary"></div>
</body>
</html>





share|improve this answer























    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%2f309176%2fhow-do-i-get-the-population-by-country-when-using-the-esri-demographics-geoproce%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









    0














    I'm excluding the part where you're referencing Google Maps. I'm not entirely sure how that comes into play with this question.



    Essentially you need to find the geometry of a country, with that you can pass that geometry into the geoprocessing service and have it use that instead of a "circle". Luckily there is a lot of data to be found on ArcGIS.com, including country boundaries.



    The below code is very close to what you want to do. (It might actually work, but sampleserver1 is giving me CORS Cross domain issues and I'm not in a position to setup a proxy to make a good request. (My issue is beyond the scope of your initial question.) Below you can see that a button press starts everything. Pressing the button sets a definition express for Country = Spain. (there are many different ways to perform a query). The selected featurelayer with the definition is sent as input to the geoprocessing service. You'll get back a response and the app is responsible for popping up a text box with the output.



    Remember, the code below will probably not just run, but it shows the pattern you need to undertake.



    Note - pieced together from GP Zonal Stats and other feature layer samples.



    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <link rel="stylesheet" href="https://js.arcgis.com/3.27/dijit/themes/claro/claro.css">
    <link rel="stylesheet" href="https://js.arcgis.com/3.27/esri/css/esri.css" />
    <script src="https://js.arcgis.com/3.27/"></script>
    <script>
    var map;

    require([
    "esri/map",
    "esri/layers/FeatureLayer",
    "esri/symbols/SimpleFillSymbol",
    "esri/symbols/SimpleLineSymbol",
    "esri/tasks/Geoprocessor",
    "dojo/dom",
    "dojo/on",
    "dojo/parser",
    "dojo/string",
    "esri/Color",
    "dijit/registry",
    "dijit/form/Button",
    "dojo/domReady!"
    ],
    function (Map, FeatureLayer, SimpleFillSymbol, SimpleLineSymbol,
    Geoprocessor, dom, on, parser, string, Color, registry
    ) {

    parser.parse();

    var featureLayer, map;

    map = new Map("map", {
    basemap: "streets",
    center: [0, 0],
    zoom: 3
    });
    gp = new Geoprocessor("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/GPServer/PopulationSummary");
    gp.setOutputSpatialReference({wkid:102100});
    gp.on("execute-complete", displayResults);


    var fieldsSelectionSymbol =
    new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
    new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
    new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.5]));
    // country boundary polygons
    featureLayer = new FeatureLayer("http://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Countries_(Generalized)/FeatureServer/0",
    {
    mode: FeatureLayer.MODE_ONDEMAND,
    outFields: ["*"]
    });
    featureLayer.setSelectionSymbol(fieldsSelectionSymbol);
    map.addLayer(featureLayer);

    function computeZonalStats() {
    featureLayer.setDefinitionExpression("Country ='Spain'");
    var params = { "inputPoly":featureLayer };
    gp.execute(params);
    }

    function displayResults(evtObj) {
    console.log(evtObj);
    var results = evtObj.results;
    var content = string.substitute("<h4>The population in the user defined polygon is ${number:dojo.number.format}.</h4>",{number:results[0].value.features[0].attributes.SUM});

    registry.byId("dialog1").setContent(content);
    registry.byId("dialog1").show();
    }
    app = {
    computeZonalStats: computeZonalStats
    };

    });
    </script>
    </head>

    <body class="claro">
    <button id="querySpainButton" data-dojo-type="dijit/form/Button" onclick="app.computeZonalStats()">Query Spain</button>
    <div id="map" style="position: relative; width:700px; height:500px; border:1px solid #000;"></div>
    <div data-dojo-type="dijit.Dialog" id="dialog1" title="Population Summary"></div>
    </body>
    </html>





    share|improve this answer




























      0














      I'm excluding the part where you're referencing Google Maps. I'm not entirely sure how that comes into play with this question.



      Essentially you need to find the geometry of a country, with that you can pass that geometry into the geoprocessing service and have it use that instead of a "circle". Luckily there is a lot of data to be found on ArcGIS.com, including country boundaries.



      The below code is very close to what you want to do. (It might actually work, but sampleserver1 is giving me CORS Cross domain issues and I'm not in a position to setup a proxy to make a good request. (My issue is beyond the scope of your initial question.) Below you can see that a button press starts everything. Pressing the button sets a definition express for Country = Spain. (there are many different ways to perform a query). The selected featurelayer with the definition is sent as input to the geoprocessing service. You'll get back a response and the app is responsible for popping up a text box with the output.



      Remember, the code below will probably not just run, but it shows the pattern you need to undertake.



      Note - pieced together from GP Zonal Stats and other feature layer samples.



      <!DOCTYPE html>
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
      <link rel="stylesheet" href="https://js.arcgis.com/3.27/dijit/themes/claro/claro.css">
      <link rel="stylesheet" href="https://js.arcgis.com/3.27/esri/css/esri.css" />
      <script src="https://js.arcgis.com/3.27/"></script>
      <script>
      var map;

      require([
      "esri/map",
      "esri/layers/FeatureLayer",
      "esri/symbols/SimpleFillSymbol",
      "esri/symbols/SimpleLineSymbol",
      "esri/tasks/Geoprocessor",
      "dojo/dom",
      "dojo/on",
      "dojo/parser",
      "dojo/string",
      "esri/Color",
      "dijit/registry",
      "dijit/form/Button",
      "dojo/domReady!"
      ],
      function (Map, FeatureLayer, SimpleFillSymbol, SimpleLineSymbol,
      Geoprocessor, dom, on, parser, string, Color, registry
      ) {

      parser.parse();

      var featureLayer, map;

      map = new Map("map", {
      basemap: "streets",
      center: [0, 0],
      zoom: 3
      });
      gp = new Geoprocessor("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/GPServer/PopulationSummary");
      gp.setOutputSpatialReference({wkid:102100});
      gp.on("execute-complete", displayResults);


      var fieldsSelectionSymbol =
      new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
      new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
      new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.5]));
      // country boundary polygons
      featureLayer = new FeatureLayer("http://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Countries_(Generalized)/FeatureServer/0",
      {
      mode: FeatureLayer.MODE_ONDEMAND,
      outFields: ["*"]
      });
      featureLayer.setSelectionSymbol(fieldsSelectionSymbol);
      map.addLayer(featureLayer);

      function computeZonalStats() {
      featureLayer.setDefinitionExpression("Country ='Spain'");
      var params = { "inputPoly":featureLayer };
      gp.execute(params);
      }

      function displayResults(evtObj) {
      console.log(evtObj);
      var results = evtObj.results;
      var content = string.substitute("<h4>The population in the user defined polygon is ${number:dojo.number.format}.</h4>",{number:results[0].value.features[0].attributes.SUM});

      registry.byId("dialog1").setContent(content);
      registry.byId("dialog1").show();
      }
      app = {
      computeZonalStats: computeZonalStats
      };

      });
      </script>
      </head>

      <body class="claro">
      <button id="querySpainButton" data-dojo-type="dijit/form/Button" onclick="app.computeZonalStats()">Query Spain</button>
      <div id="map" style="position: relative; width:700px; height:500px; border:1px solid #000;"></div>
      <div data-dojo-type="dijit.Dialog" id="dialog1" title="Population Summary"></div>
      </body>
      </html>





      share|improve this answer


























        0












        0








        0







        I'm excluding the part where you're referencing Google Maps. I'm not entirely sure how that comes into play with this question.



        Essentially you need to find the geometry of a country, with that you can pass that geometry into the geoprocessing service and have it use that instead of a "circle". Luckily there is a lot of data to be found on ArcGIS.com, including country boundaries.



        The below code is very close to what you want to do. (It might actually work, but sampleserver1 is giving me CORS Cross domain issues and I'm not in a position to setup a proxy to make a good request. (My issue is beyond the scope of your initial question.) Below you can see that a button press starts everything. Pressing the button sets a definition express for Country = Spain. (there are many different ways to perform a query). The selected featurelayer with the definition is sent as input to the geoprocessing service. You'll get back a response and the app is responsible for popping up a text box with the output.



        Remember, the code below will probably not just run, but it shows the pattern you need to undertake.



        Note - pieced together from GP Zonal Stats and other feature layer samples.



        <!DOCTYPE html>
        <html>
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
        <link rel="stylesheet" href="https://js.arcgis.com/3.27/dijit/themes/claro/claro.css">
        <link rel="stylesheet" href="https://js.arcgis.com/3.27/esri/css/esri.css" />
        <script src="https://js.arcgis.com/3.27/"></script>
        <script>
        var map;

        require([
        "esri/map",
        "esri/layers/FeatureLayer",
        "esri/symbols/SimpleFillSymbol",
        "esri/symbols/SimpleLineSymbol",
        "esri/tasks/Geoprocessor",
        "dojo/dom",
        "dojo/on",
        "dojo/parser",
        "dojo/string",
        "esri/Color",
        "dijit/registry",
        "dijit/form/Button",
        "dojo/domReady!"
        ],
        function (Map, FeatureLayer, SimpleFillSymbol, SimpleLineSymbol,
        Geoprocessor, dom, on, parser, string, Color, registry
        ) {

        parser.parse();

        var featureLayer, map;

        map = new Map("map", {
        basemap: "streets",
        center: [0, 0],
        zoom: 3
        });
        gp = new Geoprocessor("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/GPServer/PopulationSummary");
        gp.setOutputSpatialReference({wkid:102100});
        gp.on("execute-complete", displayResults);


        var fieldsSelectionSymbol =
        new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
        new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
        new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.5]));
        // country boundary polygons
        featureLayer = new FeatureLayer("http://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Countries_(Generalized)/FeatureServer/0",
        {
        mode: FeatureLayer.MODE_ONDEMAND,
        outFields: ["*"]
        });
        featureLayer.setSelectionSymbol(fieldsSelectionSymbol);
        map.addLayer(featureLayer);

        function computeZonalStats() {
        featureLayer.setDefinitionExpression("Country ='Spain'");
        var params = { "inputPoly":featureLayer };
        gp.execute(params);
        }

        function displayResults(evtObj) {
        console.log(evtObj);
        var results = evtObj.results;
        var content = string.substitute("<h4>The population in the user defined polygon is ${number:dojo.number.format}.</h4>",{number:results[0].value.features[0].attributes.SUM});

        registry.byId("dialog1").setContent(content);
        registry.byId("dialog1").show();
        }
        app = {
        computeZonalStats: computeZonalStats
        };

        });
        </script>
        </head>

        <body class="claro">
        <button id="querySpainButton" data-dojo-type="dijit/form/Button" onclick="app.computeZonalStats()">Query Spain</button>
        <div id="map" style="position: relative; width:700px; height:500px; border:1px solid #000;"></div>
        <div data-dojo-type="dijit.Dialog" id="dialog1" title="Population Summary"></div>
        </body>
        </html>





        share|improve this answer













        I'm excluding the part where you're referencing Google Maps. I'm not entirely sure how that comes into play with this question.



        Essentially you need to find the geometry of a country, with that you can pass that geometry into the geoprocessing service and have it use that instead of a "circle". Luckily there is a lot of data to be found on ArcGIS.com, including country boundaries.



        The below code is very close to what you want to do. (It might actually work, but sampleserver1 is giving me CORS Cross domain issues and I'm not in a position to setup a proxy to make a good request. (My issue is beyond the scope of your initial question.) Below you can see that a button press starts everything. Pressing the button sets a definition express for Country = Spain. (there are many different ways to perform a query). The selected featurelayer with the definition is sent as input to the geoprocessing service. You'll get back a response and the app is responsible for popping up a text box with the output.



        Remember, the code below will probably not just run, but it shows the pattern you need to undertake.



        Note - pieced together from GP Zonal Stats and other feature layer samples.



        <!DOCTYPE html>
        <html>
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
        <link rel="stylesheet" href="https://js.arcgis.com/3.27/dijit/themes/claro/claro.css">
        <link rel="stylesheet" href="https://js.arcgis.com/3.27/esri/css/esri.css" />
        <script src="https://js.arcgis.com/3.27/"></script>
        <script>
        var map;

        require([
        "esri/map",
        "esri/layers/FeatureLayer",
        "esri/symbols/SimpleFillSymbol",
        "esri/symbols/SimpleLineSymbol",
        "esri/tasks/Geoprocessor",
        "dojo/dom",
        "dojo/on",
        "dojo/parser",
        "dojo/string",
        "esri/Color",
        "dijit/registry",
        "dijit/form/Button",
        "dojo/domReady!"
        ],
        function (Map, FeatureLayer, SimpleFillSymbol, SimpleLineSymbol,
        Geoprocessor, dom, on, parser, string, Color, registry
        ) {

        parser.parse();

        var featureLayer, map;

        map = new Map("map", {
        basemap: "streets",
        center: [0, 0],
        zoom: 3
        });
        gp = new Geoprocessor("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/GPServer/PopulationSummary");
        gp.setOutputSpatialReference({wkid:102100});
        gp.on("execute-complete", displayResults);


        var fieldsSelectionSymbol =
        new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
        new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
        new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.5]));
        // country boundary polygons
        featureLayer = new FeatureLayer("http://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Countries_(Generalized)/FeatureServer/0",
        {
        mode: FeatureLayer.MODE_ONDEMAND,
        outFields: ["*"]
        });
        featureLayer.setSelectionSymbol(fieldsSelectionSymbol);
        map.addLayer(featureLayer);

        function computeZonalStats() {
        featureLayer.setDefinitionExpression("Country ='Spain'");
        var params = { "inputPoly":featureLayer };
        gp.execute(params);
        }

        function displayResults(evtObj) {
        console.log(evtObj);
        var results = evtObj.results;
        var content = string.substitute("<h4>The population in the user defined polygon is ${number:dojo.number.format}.</h4>",{number:results[0].value.features[0].attributes.SUM});

        registry.byId("dialog1").setContent(content);
        registry.byId("dialog1").show();
        }
        app = {
        computeZonalStats: computeZonalStats
        };

        });
        </script>
        </head>

        <body class="claro">
        <button id="querySpainButton" data-dojo-type="dijit/form/Button" onclick="app.computeZonalStats()">Query Spain</button>
        <div id="map" style="position: relative; width:700px; height:500px; border:1px solid #000;"></div>
        <div data-dojo-type="dijit.Dialog" id="dialog1" title="Population Summary"></div>
        </body>
        </html>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 22 at 19:27









        KHibmaKHibma

        10.2k11839




        10.2k11839






























            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%2f309176%2fhow-do-i-get-the-population-by-country-when-using-the-esri-demographics-geoproce%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 Содержание Параметры шины | Стандартизация |...