Mmm. And you can just put one of those up alongside a busy city sidewalk or next to a primary school can you?
If there's no law against you installing it, then yes you most definitely can put one in; a school being nearby doesn't affect that.
Now if it was a busy city sidewalk FIRST, and you adding that fence there is deemed a nuisance, they might be able to force you take it down, for the same reason they could force you to take down any fence you added -- forced easement (Your new fence is an eyesore or blocks a public view previously enjoyed).
City dwellers tend to not like electric fences very much, and many towns have passed a local ordinance restricting where
they can be installed to agriculturally-zoned land, OR require permits for fence projects, and may simply deny you the permit to install an electrified one.
On the other hand, if you got any required permits and had it installed it before the ordinance was passed, then the city cannot make a post-facto law to force you to remove it, provided it is on your property.