Ejercicio datos geográficos

Con la colección que se adjunta al final, realizar las siguientes operaciones:

Encontrar la ciudad que tiene una población (‘pop’) mayor de 40000
Encontrar las ciudades que tienen en ‘loc’ un valor entre 37 y 42. Puede ser cualquier valor pero ese valor tiene que cumplir las dos condiciones
Encontrar las ciudades de ‘LA’ con una población menor de 10000 habitantes
Encontrar las ciudades con una población menor de 1000 habitantes pero sólo mostrar la ciudad y el estado
Modificar la ciudad ‘CUSHMAN’ y ponerle una población de 37231 habitantes.
Modificar las ciudades de ‘LA’ con menos de 1000 habitantes y ponerles en el estado ‘##’
Eliminar las ciudades con menos de 500 habitantes.

db.ciudades.insertMany([{ "_id" : "01001", "city" : "AGAWAM", "loc" : [ -72.622739, 42.070206 ], "pop" : 15338, "state" : "MA" },
{ "_id" : "01002", "city" : "CUSHMAN", "loc" : [ -72.51564999999999, 42.377017 ], "pop" : 36963, "state" : "MA" },
{ "_id" : "01005", "city" : "BARRE", "loc" : [ -72.10835400000001, 42.409698 ], "pop" : 4546, "state" : "MA" },
{ "_id" : "01007", "city" : "BELCHERTOWN", "loc" : [ -72.41095300000001, 42.275103 ], "pop" : 10579, "state" : "MA" },
{ "_id" : "01008", "city" : "BLANDFORD", "loc" : [ -72.936114, 42.182949 ], "pop" : 1240, "state" : "MA" },
{ "_id" : "01010", "city" : "BRIMFIELD", "loc" : [ -72.188455, 42.116543 ], "pop" : 3706, "state" : "MA" },
{ "_id" : "01011", "city" : "CHESTER", "loc" : [ -72.988761, 42.279421 ], "pop" : 1688, "state" : "MA" },
{ "_id" : "01012", "city" : "CHESTERFIELD", "loc" : [ -72.833309, 42.38167 ], "pop" : 177, "state" : "MA" },
{ "_id" : "01013", "city" : "CHICOPEE", "loc" : [ -72.607962, 42.162046 ], "pop" : 23396, "state" : "MA" },
{ "_id" : "29372", "city" : "PACOLET", "loc" : [ -81.758703, 34.901708 ], "pop" : 4129, "state" : "SC" },
{ "_id" : "29374", "city" : "GLENN SPRINGS", "loc" : [ -81.85785300000001, 34.774808 ], "pop" : 4588, "state" : "SC" },
{ "_id" : "29376", "city" : "ROEBUCK", "loc" : [ -81.95255, 34.8688 ], "pop" : 5009, "state" : "SC" },
{ "_id" : "29379", "city" : "UNION", "loc" : [ -81.62023499999999, 34.726855 ], "pop" : 22553, "state" : "SC" },
{ "_id" : "29384", "city" : "WATERLOO", "loc" : [ -82.087968, 34.33673 ], "pop" : 2992, "state" : "SC" },
{ "_id" : "29385", "city" : "WELLFORD", "loc" : [ -82.09270600000001, 34.951394 ], "pop" : 6637, "state" : "SC" },
{ "_id" : "29388", "city" : "WOODRUFF", "loc" : [ -82.044658, 34.757864 ], "pop" : 10206, "state" : "SC" },
{ "_id" : "29401", "city" : "CHARLESTON", "loc" : [ -79.93706899999999, 32.779506 ], "pop" : 12475, "state" : "SC" },
{ "_id" : "29403", "city" : "CHARLESTON", "loc" : [ -79.94928299999999, 32.797575 ], "pop" : 24620, "state" : "SC" },
{ "_id" : "29404", "city" : "CHARLESTON", "loc" : [ -80.06768700000001, 32.895816 ], "pop" : 5420, "state" : "SC" },
{ "_id" : "29405", "city" : "CHARLESTON", "loc" : [ -79.97644200000001, 32.851206 ], "pop" : 30621, "state" : "SC" },
{ "_id" : "30136", "city" : "DULUTH", "loc" : [ -84.15793600000001, 33.98619 ], "pop" : 30932, "state" : "GA" },
{ "_id" : "30137", "city" : "EMERSON", "loc" : [ -84.75704500000001, 34.119969 ], "pop" : 1353, "state" : "GA" },
{ "_id" : "30139", "city" : "FAIRMOUNT", "loc" : [ -84.76687800000001, 34.465241 ], "pop" : 3405, "state" : "GA" },
{ "_id" : "30140", "city" : "FELTON", "loc" : [ -85.220781, 33.887066 ], "pop" : 489, "state" : "GA" },
{ "_id" : "30141", "city" : "HIRAM", "loc" : [ -84.769875, 33.867286 ], "pop" : 6613, "state" : "GA" },
{ "_id" : "30143", "city" : "JASPER", "loc" : [ -84.475881, 34.461965 ], "pop" : 8256, "state" : "GA" },
{ "_id" : "30144", "city" : "KENNESAW", "loc" : [ -84.60466, 34.028656 ], "pop" : 37120, "state" : "GA" },
{ "_id" : "30145", "city" : "KINGSTON", "loc" : [ -84.997299, 34.250053 ], "pop" : 2534, "state" : "GA" },
{ "_id" : "35089", "city" : "KELLYTON", "loc" : [ -86.04839699999999, 32.979068 ], "pop" : 1584, "state" : "AL" },
{ "_id" : "35091", "city" : "KIMBERLY", "loc" : [ -86.80841700000001, 33.768355 ], "pop" : 1045, "state" : "AL" },
{ "_id" : "35094", "city" : "LEEDS", "loc" : [ -86.57482400000001, 33.528333 ], "pop" : 10421, "state" : "AL" },
{ "_id" : "35096", "city" : "LINCOLN", "loc" : [ -86.111152, 33.605913 ], "pop" : 5033, "state" : "AL" },
{ "_id" : "35098", "city" : "LOGAN", "loc" : [ -87.038115, 34.184079 ], "pop" : 2379, "state" : "AL" },
{ "_id" : "35111", "city" : "MC CALLA", "loc" : [ -87.102379, 33.284546 ], "pop" : 8147, "state" : "AL" },
{ "_id" : "35114", "city" : "MAYLENE", "loc" : [ -86.87274499999999, 33.231694 ], "pop" : 3727, "state" : "AL" },
{ "_id" : "47124", "city" : "GREENVILLE", "loc" : [ -86.00829899999999, 38.353533 ], "pop" : 1162, "state" : "IN" },
{ "_id" : "47125", "city" : "HARDINSBURG", "loc" : [ -86.317983, 38.462599 ], "pop" : 2496, "state" : "IN" },
{ "_id" : "47126", "city" : "HENRYVILLE", "loc" : [ -85.773403, 38.539829 ], "pop" : 2648, "state" : "IN" },
{ "_id" : "47129", "city" : "CLARKSVILLE", "loc" : [ -85.524438, 38.537273 ], "pop" : 379, "state" : "IN" },
{ "_id" : "47130", "city" : "JEFFERSONVILLE", "loc" : [ -85.735885, 38.307767 ], "pop" : 56543, "state" : "IN" },
{ "_id" : "71060", "city" : "MOORINGSPORT", "loc" : [ -93.973018, 32.66258 ], "pop" : 2838, "state" : "LA" },
{ "_id" : "71061", "city" : "OIL CITY", "loc" : [ -93.983844, 32.745107 ], "pop" : 1874, "state" : "LA" },
{ "_id" : "71063", "city" : "PELICAN", "loc" : [ -93.563361, 31.896563 ], "pop" : 998, "state" : "LA" },
{ "_id" : "71064", "city" : "PLAIN DEALING", "loc" : [ -93.690534, 32.907419 ], "pop" : 4904, "state" : "LA" },
{ "_id" : "71065", "city" : "PLEASANT HILL", "loc" : [ -93.513594, 31.808577 ], "pop" : 1338, "state" : "LA" },
{ "_id" : "71862", "city" : "WASHINGTON", "loc" : [ -93.673529, 33.754596 ], "pop" : 821, "state" : "AR" },
{ "_id" : "71864", "city" : "WILLISVILLE", "loc" : [ -93.31211999999999, 33.484731 ], "pop" : 888, "state" : "AR" },
{ "_id" : "71865", "city" : "WILTON", "loc" : [ -94.135746, 33.734794 ], "pop" : 983, "state" : "AR" },
{ "_id" : "71866", "city" : "WINTHROP", "loc" : [ -94.395174, 33.858321 ], "pop" : 950, "state" : "AR" },
{ "_id" : "71901", "city" : "LAKE CATHERINE", "loc" : [ -93.02602400000001, 34.501475 ], "pop" : 27402, "state" : "AR" },
{ "_id" : "71909", "city" : "HOT SPRINGS VILL", "loc" : [ -93.00638600000001, 34.65862 ], "pop" : 8268, "state" : "AR" }])

Publicado por

Avatar del usuario

Juan Pablo Fuentes

Formador de programación y bases de datos